/**
 * Copyright (C), 2001-2031, www.bosssof.com.cn
 * FileName: UserApi.java
 * Author: WangXin
 * Date: 2024/6/2 下午5:43
 * Description:
 * 用户接口
 * History:
 * Date          Author   Version  Desc
 * 2024-01-01    bosssoft  1.0.0   initialize this file
 */
package com.bosssoft.g1.api;

import com.bosssoft.g1.common.data.vo.CommonResponse;
import com.bosssoft.g1.dto.PageDTO;
import com.bosssoft.g1.dto.UserDTO;
import com.bosssoft.g1.dto.UserRoleRequestDTO;
import com.bosssoft.g1.entity.Role;
import com.bosssoft.g1.query.UserQuery;
import com.bosssoft.g1.vo.IdNameVO;
import com.bosssoft.g1.vo.UserVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;

/**
 * @className: UserApi
 * @description: 解决什么问题：
 * 演示线程池的正确使用
 * 主要方法和数据成员：
 * methodxx 使用 ThreadPoolExecutor创建线程进行任务操作
 * 注意事项：
 * 例如：该类需要从容器获取不可以new
 * @author: WangXin
 * @date: 2024/6/2下午5:43
 * @since 1.0
 **/
@CrossOrigin
@Api(tags = "用户管理 ", value = "/v1/user")
@RequestMapping("/v1/user")
@Validated
public interface UserApi {

    /**
     * 开始时获取所有用户信息
     * @return: CommonResponse
     */
    @ApiOperation( value = "查询角色")
    @GetMapping( "/all")
    @ResponseBody
    CommonResponse<PageInfo<UserVO>> getAllUsers(PageDTO pageDTO);

    /**
     * 获取所有部门id和name
     * @return List<DepartmentDTO>
     */
    @ApiOperation(value = "获取所有部门", notes = "notes说明")
    @ApiResponses({
            @ApiResponse(code = 0, message = "请求成功"),
            @ApiResponse(code = -1, message = "没有更新记录,非0码则代表失败")
    }
    )
    @GetMapping("/getAllDepartment")
    CommonResponse<List<IdNameVO>> getAllDepartment();

    /**
     * 获取所有角色id和name
     * @return List<RoleVO>
     */
    @ApiOperation(value = "获取所有角色", notes = "notes说明")
    @ApiResponses({
            @ApiResponse(code = 0, message = "请求成功"),
            @ApiResponse(code = -1, message = "没有更新记录,非0码则代表失败")
    }
    )
    @GetMapping("/getAllRole")
    CommonResponse<List<IdNameVO>> getAllRole();

    /**
     * 获取所有职位id和name
     * @return List<RoleVO>
     */
    @ApiOperation(value = "获取所有职位", notes = "notes说明")
    @ApiResponses({
            @ApiResponse(code = 0, message = "请求成功"),
            @ApiResponse(code = -1, message = "没有更新记录,非0码则代表失败")
    }
    )
    @GetMapping("/getAllPosition")
    CommonResponse<List<IdNameVO>> getAllPosition();

    /**
     * 通过用户名，工号，电话，角色查询
     * @param:  id
     * @return: CommonResponse
     */
    @ApiOperation( value = "查询用户")
    @PostMapping( "/query")
    @ResponseBody
    CommonResponse<PageInfo<UserVO>> queryUser(@RequestBody UserQuery userQuery);

    /**
     * 通过id查询用户，但好像用户不能直接在请求体里传Long类型，不能进行转化
     * @param:  id
     * @return: CommonResponse
     */
    @ApiOperation( value = "查询用户")
    @GetMapping( "/queryId")
    @ResponseBody
    CommonResponse<UserVO> queryUserById(Long id);

    /**
     * 界面调用接口增加用户
     *
     * @param userDTO 用户信息
     * @return true成功 false失败
     */

    @ApiOperation(value = "增加用户", notes = "界面增加用户")
    @ApiResponses({
            @ApiResponse(code = 0, message = "请求成功"),
            @ApiResponse(code = -1, message = "请求执行没有成功但是发生异常")
    }
    )
    @PostMapping("/add")
    CommonResponse<Boolean> add(@NotNull @Valid @RequestBody @ApiParam(value = "用户数据", required = true) UserDTO userDTO);

    /**
     * 删除用户
     *
     * @param id 用户Id
     * @return true 成功 false失败
     */
    @ApiOperation(value = "删除用户通过id", notes = "通过id删除用户")
    @ApiResponses({
            @ApiResponse(code = 0, message = "请求成功"),
            @ApiResponse(code = -1, message = "没有更新记录,非0码则代表失败")
    }
    )
    @DeleteMapping("/remove")
    @ResponseBody
    CommonResponse<Boolean> remove(@NotNull @RequestParam Long id);

    /**
     * 批量删除用户
     *
     * @param userDTO
     * @return
     */
    @ApiOperation(value = "批量删除用户通过id", response = Boolean.class, notes = "notes说明")
    @ApiResponses({
            @ApiResponse(code = 0, message = "请求成功"),
            @ApiResponse(code = -1, message = "没有更新记录,非0码则代表失败")
    }
    )
    @DeleteMapping("/batchRemove")
    CommonResponse<Boolean> batchRemove(@NotEmpty @RequestBody List<UserDTO> userDTO );

    /**
     * 通过id修改用户信息——编辑
     * @param userDTO
     * @return CommonResponse
     */
    @ApiOperation("编辑用户信息")
    @PutMapping("/edit")
    @ResponseBody
    CommonResponse<Boolean> updateUser(@NotNull @RequestBody UserDTO userDTO);

    /**
     * 用户分配
     * @param userRoleRequest
     * @return CommonResponse
     */
    @PostMapping("/userAssign")
    @ApiOperation(value = "用户分配", response = Boolean.class, notes = "notes说明")
    @ApiImplicitParams({@ApiImplicitParam(name = "userRoleRequest", required = true, dataType = "UserRoleRequest", paramType = "body")})
    @ApiResponses({
            @ApiResponse(code = 0, message = "请求成功"),
            @ApiResponse(code = -1, message = "没有更新记录,非0码则代表失败")
    })
    CommonResponse<Boolean> userAssign(@RequestBody UserRoleRequestDTO userRoleRequest);

    /**
     * 获取公司角色列表
     * @param userId
     * @return CommonResponse
     */
    @GetMapping("/getCompanyRoleList")
    @ApiOperation(value = "用户分配", response = Boolean.class, notes = "notes说明")
    @ApiImplicitParams({@ApiImplicitParam(name = "idVersions", required = true, dataType = "IdVersion", paramType = "body")})
    @ApiResponses({@ApiResponse(code = 0, message = "请求成功"), @ApiResponse(code = -1, message = "没有更新记录,非0码则代表失败")})
    CommonResponse<PageInfo<Role>> getCompanyRoleList(@RequestParam("userId") Long userId, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize);

    /**
     * 启功能
     * @param ids
     * @return CommonResponse
     */
    @PostMapping("/start")
    @ApiOperation(value = "启功能", response = Boolean.class, notes = "notes说明")
    @ApiImplicitParams({@ApiImplicitParam(name = "idVersions", required = true, dataType = "IdVersion", paramType = "body")})
    @ApiResponses({@ApiResponse(code = 0, message = "请求成功"), @ApiResponse(code = -1, message = "没有更新记录,非0码则代表失败")})
    CommonResponse<Boolean> start(@RequestBody List<Long> ids);

    /**
     * 停功能
     * @param ids
     * @return CommonResponse
     */
    @PostMapping("/stop")
    @ApiOperation(value = "停功能", response = Boolean.class, notes = "notes说明")
    @ApiImplicitParams({@ApiImplicitParam(name = "idVersions", required = true, dataType = "IdVersion", paramType = "body")})
    @ApiResponses({@ApiResponse(code = 0, message = "请求成功"), @ApiResponse(code = -1, message = "没有更新记录,非0码则代表失败")})
    CommonResponse<Boolean> stop(@RequestBody List<Long> ids);

    /**
     * 显示用户的角色职位部门树
     * @param id
     * @return
     */
    @ApiOperation(value = "获取用户的资源")
    @GetMapping(value = "/tree")
    CommonResponse<Map<String,List>> getUserRolePositionDepartmentTree(@NotNull @PathVariable("id")  Long id);


//    /**
//     * 通过查找更新用户信息
//     * @param userQuery 用户信息包含 id
//     * @return true成功 false失败
//     */
//    @ApiOperation(value = "查询用户列表接口",notes = "支持模糊查询")
//    @ApiResponses({
//            @ApiResponse(code = 0,message = "请求成功"),
//            @ApiResponse(code=-1,message = "没有更新记录,非0码则代表失败")
//    })
//    @GetMapping("/user")
//    CommonResponse<CommonPage<UserDTO>> search(@NotNull @Valid @RequestBody UserQuery userQuery);

    /**
     * 根据部门id查询用户主页
     * @param pageNum
     * @param pageSize
     * @param id
     * @return
     */
    @ApiOperation(value = "用户树——部门")
    @GetMapping(value = "/tree/department")
    CommonResponse<PageInfo<UserVO>> getUserByDepartment(@NotNull @Valid int pageNum,int pageSize,Long id);

    /**
     * 根据职位id查询用户主页
     * @param pageNum
     * @param pageSize
     * @param id
     * @return
     */
    @ApiOperation(value = "用户树——职位")
    @GetMapping(value = "/tree/position")
    CommonResponse<PageInfo<UserVO>> getUserByPosition(@NotNull @Valid int pageNum,int pageSize,Long id);

    /**
     * 根据角色id查询用户主页
     * @param pageNum
     * @param pageSize
     * @param id
     * @return
     */
    @ApiOperation(value = "用户树——角色")
    @GetMapping(value = "/tree/role")
    CommonResponse<PageInfo<UserVO>> getUserByRole(@NotNull @Valid int pageNum,int pageSize,Long id);
}

